package com.lin.fengxiu.util;

import com.lin.fengxiu.bo.PageCounter;

import java.util.Date;

/**
 * @ClassName CommonUtil
 * @Description TODO
 * @Author wushaopei
 * @Date 2021/3/14 11:42
 * @Version 1.0
 */
public class CommonUtil {

    public static PageCounter convertToPageParameter(Integer start, Integer count){
        int pageNum = start / count;

        PageCounter pageCounter = PageCounter.builder()
                .page(pageNum)
                .count(count)
                .build();
        return pageCounter;
    }

    /**
     * @Description TODO 优惠券是否过期，优惠券从属于活动，活动过期则优惠券过期
     * @param date
     * @param start
     * @param end
     * @return
     */
    public static Boolean isInTimeLine(Date date, Date start, Date end){
        Long time = date.getTime();
        Long startTime = start.getTime();
        Long endTime = end.getTime();
        if( time > startTime && time < endTime){
            return true;
        }
        return false;
    }
}
